package com.ctr_flower.service.impl;

import com.ctr_flower.entity.TbDiscuss;
import com.ctr_flower.dao.TbDiscussDao;
import com.ctr_flower.service.TbDiscussService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TbDiscuss)表服务实现类
 *
 * @author makejava
 * @since 2020-08-23 12:06:00
 */
@Service("tbDiscussService")
public class TbDiscussServiceImpl implements TbDiscussService {
    @Resource
    private TbDiscussDao tbDiscussDao;

    /**
     * 通过ID查询单条数据
     *
     * @param discussId 主键
     * @return 实例对象
     */
    @Override
    public TbDiscuss queryById(Integer discussId) {
        return this.tbDiscussDao.queryById(discussId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TbDiscuss> queryAllByLimit(int offset, int limit) {
        return this.tbDiscussDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tbDiscuss 实例对象
     * @return 实例对象
     */
    @Override
    public TbDiscuss insert(TbDiscuss tbDiscuss) {
        this.tbDiscussDao.insert(tbDiscuss);
        return tbDiscuss;
    }

    /**
     * 修改数据
     *
     * @param tbDiscuss 实例对象
     * @return 实例对象
     */
    @Override
    public TbDiscuss update(TbDiscuss tbDiscuss) {
        this.tbDiscussDao.update(tbDiscuss);
        return this.queryById(tbDiscuss.getDiscussId());
    }

    /**
     * 通过主键删除数据
     *
     * @param discussId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer discussId) {
        return this.tbDiscussDao.deleteById(discussId) > 0;
    }
}